﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.Mvc;
using Model;


namespace EasyUIDemo.MVC.Controllers
{
    public class AuditController : Controller
    {
        //
        // GET: /Audit/

        public ActionResult AuditIndex()
        {
            return View();
        }


        
        public ActionResult AuditList(int pageindex=1)
        {
            var pronum = Request["pronum"];
            int pagesize = 8;
            string strwhere = "";
            if (pronum != null)
            {
                strwhere += " and a.projectnumber="+pronum;
            }

            using (HttpClient client = new HttpClient())
            {
                string strurl = "http://localhost:63805/apis/audit/getlist?pageindex="+pageindex+"&pagesize="+pagesize+"&wherestr="+strwhere;
                var result = client.GetAsync(strurl).Result;
                if (result.IsSuccessStatusCode)
                {
                    var BasicModel = result.Content.ReadAsStringAsync().Result;
                    var list = Newtonsoft.Json.JsonConvert.DeserializeObject<pagelist<Basic_Info>>(BasicModel);
                    return View(list.getlist);
                }
                else
                {

                    return Content("<script>alert('"+result.StatusCode+"')</script>");
                }
            }
        }


        
        



    }
}
